package dreamCookGame;

import java.awt.image.BufferedImage;

public abstract class Scene {

	public String _backgroundImgName;
	public BufferedImage _backgroundImg;
	public String _foregroundImgName;
	public BufferedImage _foregroundImg;
	public int _foregroundX;
    public int _foregroundY;
	public Item[] _itemsBack;
	public Item[] _itemsFront;
	public Character[] _characters;
	public String _name;
	
	public Scene(String _name, String backgroundImgName, String foregroundImgName, int foregroundX, int foregroundY, Character[] characters, Item[] itemsBack, Item[] itemsFront) {
		_backgroundImgName = backgroundImgName;
		_foregroundImgName = foregroundImgName;
		_foregroundX = foregroundX;
		_foregroundY = foregroundY;
		_itemsBack = itemsBack;
		_itemsFront = itemsFront;
		_characters = characters;
	}
	
	public void loadImage(BufferedImage image) {
		_backgroundImg = image;
	}
	
	public void loadResources(References reference) {
		_backgroundImg = reference.getImage(_backgroundImgName);
		
		if(_foregroundImgName != null)
			_foregroundImg = reference.getImage(_foregroundImgName);
		
		if(_itemsBack != null)
			for(int i = 0; i < _itemsBack.length; i++)
				_itemsBack[i].loadResources(reference);
		
		if(_itemsFront != null)
			for(int i = 0; i < _itemsFront.length; i++)
				_itemsFront[i].loadResources(reference);
		
		if(_characters != null) {
			//TODO: Change so that all character images are loaded the same way (Brittany)
			//_characters[0].loadWalkingImages(reference);
			for(int i = 0; i < _characters.length; i++)
				_characters[i].loadResources(reference);
		}
	}

}
